<?php

namespace App\Http\Requests\Admin\CompanyContract;
use App\Http\Requests\Request;
use Validator;

class UpdateContractRequest extends Request{
    public function authorize(){
        return true;
    }
    public function rules(){

        //自定义电话号码验证规则改写
        Validator::extend('check_responsible', function($attribute, $value, $parameters) {
            if($value == '0'){
                if(empty($this->responsible)){
                    return false;
                }else{
                    return true;
                }
            }else{
                return true;
            }
        });

        return [
            'start_time' => 'required',
            'end_time'=>'required',
            'vip_resume_number'=>'integer',
            'vip_integral'=>'integer',
            'vip_post_number'=>'integer',
            'resume_number'=>'integer',
            'integral'=>'integer',
            'responsible_crm_uid'=>'required|check_responsible',
            'pay'=>'required',
            'money'=>'required|numeric',
            'pay_time'=>'required'
        ];
    }
    public function messages(){
        return [
            'start_time.required' => '请选择服务开始时间',
            'end_time.required' => '请选择服务结束时间',
            'vip_resume_number.integer'=>'会员期内简历数必须是整数！',
            'vip_integral.integer'=>'会员期内积分必须是整数！',
            'vip_post_number.integer'=>'会员期内职位数必须是整数！',
            'resume_number.integer'=>'非会员简历数必须是整数！',
            'integral.integer'=>'非会员积分必须是整数！',
            'responsible_crm_uid.required'=>'请选择销售代表！',
            'responsible_crm_uid.check_responsible'=>'选择其他,必须填写销售负责人',
            'pay.required'=>'请选择支付方式！',
            'money.numeric'=>'金额必须是一个数字！',
            'money.required'=>'金额必须存在！',
            'pay_time.required'=>'支付时间不能为空！'
        ];
    }
}
